/**
 * 处理发送请求的参数，把conditions对象中空的值过滤掉并删除key
 * @author lizhao
 * @param {object} param 请求接口的参数
 * @return {string} 返回处理后的值
 * @exapmle 表示示例
 * **/
export function params(param: Object): Object {
	let conditions = param.conditions;
	if (conditions) {
		for (let i in conditions) {
			if (conditions[i] != '') {
				for (let k in conditions[i]) {
					let type = typeof conditions[i][k]
					if(type=='string' && conditions[i][k] == ''){
						delete conditions[i][k]
					}
					if(type=='object'&&conditions[i][k].length==0){
						delete conditions[i][k]
					}
				}
				let string = JSON.stringify(conditions[i])
				if(string=="{}"||string==''||string=="[]"){
					delete conditions[i]
				}
			} else {
				delete conditions[i]
			}
		}
		//由于Object.entries会导致对象引用断掉舍弃
		// for (let [key, value] of Object.entries(conditions)) {
		// 	console.log(key, value);
		// 	if (key && value != '') {
		// 		for (let [k, v] of Object.entries(value)) {
		// 			console.log('字段对象', k, v);
		// 			if (v== '') {
		// 				delete v[k]
		// 				console.log('删除结果', v);
		// 			}
		// 		}
		// 	} else {
		// 		delete conditions[key]
		// 	}
		// }
	}
	return param
}